home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
term
/
term34Source.lha
/
TranslationPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-16
|
20KB
|
808 lines
/*
** TranslationPanel.c
**
** Character code translation editing panel
**
** Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
/* The character table. */
STATIC STRPTR CharCodes[256] =
{
"NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS" ,"HT" ,"LF" ,"VT" ,"FF" ,"CR" ,"SO" ,"SI" ,
"DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM" ,"SUB","ESC","FS" ,"GS" ,"RS" ,"US" ,
"SP" , "!" , "\"", "#" , "$" , "%" , "&" , "'" , "(" , ")" , "*" , "+" , "," , "-" , "." , "/" ,
"0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , ":" , ";" , "<" , "=" , ">" , "?" ,
"@" , "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" , "L" , "M" , "N" , "O" ,
"P" , "Q" , "R" , "S" , "T" , "U" , "V" , "W" , "X" , "Y" , "Z" , "[" , "\\", "]" , "^" , "_" ,
"`" , "a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" , "i" , "j" , "k" , "l" , "m" , "n" , "o" ,
"p" , "q" , "r" , "s" , "t" , "u" , "v" , "w" , "x" , "y" , "z" , "{" , "|" , "}" , "~" ,"DEL",
"128","129","130","131","132","133","134","135","136","137","138","139","140","141","SS2","SS3",
"DCS","145","146","147","148","149","150","151","152","153","154","CSI","ST" ,"OSC","PM" ,"APC",
"NBS", "¡" , "¢" , "£" , "¤" , "¥" , "¦" , "§" , "¨" , "©" , "ª" , "«" , "¬" ,"SHY", "®" , "¯" ,
"°" , "±" , "²" , "³" , "´" , "µ" , "¶" , "·" , "¸" , "¹" , "º" , "»" , "¼" , "½" , "¾" , "¿" ,
"À" , "Á" , "Â" , "Ã" , "Ä" , "Å" , "Æ" , "Ç" , "È" , "É" , "Ê" , "Ë" , "Ì" , "Í" , "Î" , "Ï" ,
"Ð" , "Ñ" , "Ò" , "Ó" , "Ô" , "Õ" , "Ö" , "×" , "Ø" , "Ù" , "Ú" , "Û" , "Ü" , "Ý" , "Þ" , "ß" ,
"à" , "á" , "â" , "ã" , "ä" , "å" , "æ" , "ç" , "è" , "é" , "ê" , "ë" , "ì" , "í" , "î" , "ï" ,
"ð" , "ñ" , "ò" , "ó" , "ô" , "õ" , "ö" , "÷" , "ø" , "ù" , "ú" , "û" , "ü" , "ý" , "þ" , "ÿ"
};
/* Main control panel gadget IDs. */
enum { MAINGAD_HALF=256,MAINGAD_USE,MAINGAD_LOAD,MAINGAD_SAVE,MAINGAD_CANCEL };
/* The local settings panel gadget IDs. */
enum { SUBGAD_CODE,SUBGAD_SEND,SUBGAD_RECEIVE,SUBGAD_USE,SUBGAD_CANCEL };
STATIC STRPTR Halfs[] =
{
"NUL-DEL",
"128-\"ÿ\"",
NULL
};
STATIC struct Gadget *
CreateAllMainGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,BYTE *Half)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter;
FOREVER
{
SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
WORD i,From,To;
switch(*Half)
{
case 0:
From = 0;
To = 127;
break;
case 1:
From = 128;
To = 255;
break;
case 2:
From = 0;
To = 255;
break;
}
SZ_ResetMaxWidth();
for(i = From ; i <= To ; i++)
SZ_UpdateMaxWidth(BUTTON_KIND,CharCodes[i],0,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
for(i = From ; i <= To ; i++)
{
if(i == (To + 1) / 2 - 1)
{
if(SZ_GetWindowHeight() > Window -> WScreen -> Height / 2)
{
if(*Half == 2)
{
*Half = 0;
To = 127;
}
}
}
NewGadget . ng_GadgetText = CharCodes[i];
NewGadget . ng_GadgetID = i;
if(!(i % 16))
{
GadgetArray[i] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_GroupCount, 16,
SZ_AlignBottom, TRUE,
TAG_DONE);
}
else
{
GadgetArray[i] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_GroupNext, TRUE,
TAG_DONE);
}
}
if(*Half < 2)
{
Counter = MAINGAD_HALF;
NewGadget . ng_GadgetText = LocaleString(MSG_TRANSLATIONPANEL_CHARACTER_PAGE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AlignExtra, TRUE,
SZ_AlignCentre, TRUE,
SZ_AlignBottom, TRUE,
GTCY_Labels, Halfs,
GTCY_Active, *Half,
TAG_DONE);
}
else
Counter = MAINGAD_USE;
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_LOAD_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignExtra, TRUE,
SZ_AlignLeft, TRUE,
SZ_AlignBottom, TRUE,
SZ_GroupCount, 4,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_LOAD_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_GroupNext, TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_SAVE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_GroupNext, TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_GroupNext, TRUE,
TAG_DONE);
if(SZ_GetWindowHeight() > Window -> WScreen -> Height)
{
FreeGadgets(*GadgetList);
*GadgetList = NULL;
if(*Half == 2)
*Half = 0;
else
return(NULL);
}
else
return(Gadget);
}
else
return(NULL);
}
}
STATIC struct Gadget *
CreateAllSubGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,STRPTR Buffer)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
SZ_ResetMaxWidth();
SZ_UpdateMaxWidth(TEXT_KIND,NULL,strlen(Buffer),NULL);
SZ_UpdateMaxWidth(STRING_KIND,NULL,40,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
SZ_InitWidth();
NewGadget . ng_GadgetText = LocaleString(MSG_TRANSLATIONPANEL_CHARACTER_CODE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = PLACETEXT_ABOVE;
GadgetArray[Counter++] = Gadget = CreateGadget(TEXT_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AlignCentre, TRUE,
SZ_Chars, strlen(Buffer),
GTTX_Text, Buffer,
GTTX_Border, TRUE,
GTTX_Justification, GTJ_CENTER,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_TRANSLATIONPANEL_SEND_CODE_AS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AlignExtra, TRUE,
SZ_AlignBottom, TRUE,
SZ_AlignLeft, TRUE,
SZ_Chars, 40,
STRINGA_Justification, GACT_STRINGCENTER,
GTST_MaxChars, 255,
GA_Immediate, TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_TRANSLATIONPANEL_RECEIVE_CODE_AS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AlignExtra, TRUE,
SZ_AlignBottom, TRUE,
SZ_AlignLeft, TRUE,
SZ_Chars, 40,
STRINGA_Justification, GACT_STRINGCENTER,
GTST_MaxChars, 255,
GA_Immediate, TRUE,
TAG_DONE);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignExtra, TRUE,
SZ_AlignLeft, TRUE,
SZ_AlignBottom, TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignRight, TRUE,
TAG_DONE);
}
return(Gadget);
}
STATIC BYTE
SubPanel(UBYTE CharCode)
{
struct Window *PanelWindow;
struct Gadget *GadgetList = NULL;
struct Gadget *GadgetArray[SUBGAD_CANCEL + 1];
BYTE Result = FALSE;
if(CharCodes[CharCode][0] == '1' && CharCodes[CharCode][1])
strcpy(SharedBuffer,CharCodes[CharCode]);
else
SPrintf(SharedBuffer,"%ld (\"%s\")",CharCode,CharCodes[CharCode]);
if(CreateAllSubGadgets(GadgetArray,&GadgetList,SharedBuffer))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
WA_Top, GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight()) / 2,
WA_Width, SZ_GetWindowWidth(),
WA_Height, SZ_GetWindowHeight(),
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Window -> WScreen,
WA_IDCMP, IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_CLOSEWINDOW | IDCMP_RAWKEY | IDCMP_VANILLAKEY | BUTTONIDCMP | STRINGIDCMP,
WA_Title, LocaleString(MSG_TRANSLATIONPANEL_CHARACTER_CODE_TRANSLATION_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG IClass,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
STRPTR SendText = NULL,
ReceiveText = NULL;
GuideContext(CONTEXT_TRANSLATION);
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
ActiveGadget = NULL;
if(SendTable[CharCode])
{
TranslateBack(SendTable[CharCode] -> String,SendTable[CharCode] -> Len,SharedBuffer);
GT_SetGadgetAttrs(GadgetArray[SUBGAD_SEND],PanelWindow,NULL,
GTST_String,SharedBuffer,
TAG_DONE);
}
if(ReceiveTable[CharCode])
{
TranslateBack(ReceiveTable[CharCode] -> String,ReceiveTable[CharCode] -> Len,SharedBuffer);
GT_SetGadgetAttrs(GadgetArray[SUBGAD_RECEIVE],PanelWindow,NULL,
GTST_String,SharedBuffer,
TAG_DONE);
}
SetSignal(0,SIG_BREAK);
while(!Terminated)
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
IClass = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
KeySelect(GadgetArray,SUBGAD_CANCEL,Code,PanelWindow,&Gadget,&IClass,&Code);
if(IClass == IDCMP_ACTIVEWINDOW && ActiveGadget)
ActivateGadget(ActiveGadget,PanelWindow,NULL);
if(IClass == IDCMP_GADGETDOWN)
{
if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
ActiveGadget = Gadget;
}
if(IClass == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
if(IClass == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case SUBGAD_SEND:
ActivateGadget(ActiveGadget = GadgetArray[SUBGAD_RECEIVE],PanelWindow,NULL);
break;
case SUBGAD_USE:
SendText = SZ_GetString(GadgetArray[SUBGAD_SEND]);
ReceiveText = SZ_GetString(GadgetArray[SUBGAD_RECEIVE]);
Terminated = TRUE;
break;
case SUBGAD_CANCEL:
Terminated = TRUE;
break;
}
}
}
}
if(GadgetList)
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
if(SendText)
{
if(*SendText)
{
struct TranslationEntry *Entry = AllocTranslationEntry(SendText);
if(Entry)
{
if(SendTable[CharCode])
FreeTranslationEntry(SendTable[CharCode]);
SendTable[CharCode] = Entry;
Result = TRUE;
}
}
else
{
if(SendTable[CharCode])
FreeTranslationEntry(SendTable[CharCode]);
SendTable[CharCode] = NULL;
Result = TRUE;
}
}
if(ReceiveText)
{
if(*ReceiveText)
{
struct TranslationEntry *Entry = AllocTranslationEntry(ReceiveText);
if(Entry)
{
if(ReceiveTable[CharCode])
FreeTranslationEntry(ReceiveTable[CharCode]);
ReceiveTable[CharCode] = Entry;
Result = TRUE;
}
}
else
{
if(ReceiveTable[CharCode])
FreeTranslationEntry(ReceiveTable[CharCode]);
ReceiveTable[CharCode] = NULL;
Result = TRUE;
}
}
PopWindow();
CloseWindow(PanelWindow);
}
}
FreeGadgets(GadgetList);
return(Result);
}
BYTE
TranslationPanel()
{
struct Window *PanelWindow;
struct Gadget *GadgetList = NULL;
struct Gadget **GadgetArray;
BYTE Half = 2;
BYTE MadeChanges = FALSE,
Created = FALSE;
if(!SendTable)
{
if(!(SendTable = AllocTranslationTable()))
{
DisplayBeep(Window -> WScreen);
return(FALSE);
}
if(!(ReceiveTable = AllocTranslationTable()))
{
DisplayBeep(Window -> WScreen);
FreeTranslationTable(SendTable);
SendTable = NULL;
return(FALSE);
}
if(!FillTranslationTable(SendTable))
{
DisplayBeep(Window -> WScreen);
FreeTranslationTable(SendTable);
SendTable = NULL;
FreeTranslationTable(ReceiveTable);
ReceiveTable = NULL;
return(FALSE);
}
if(!FillTranslationTable(ReceiveTable))
{
DisplayBeep(Window -> WScreen);
FreeTranslationTable(SendTable);
SendTable = NULL;
FreeTranslationTable(ReceiveTable);
ReceiveTable = NULL;
return(FALSE);
}
Created = TRUE;
}
if(GadgetArray = (struct Gadget **)AllocVec(sizeof(struct Gadget *) * (MAINGAD_CANCEL + 1),MEMF_ANY | MEMF_CLEAR))
{
if(CreateAllMainGadgets(GadgetArray,&GadgetList,&Half))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
WA_Top, GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight()) / 2,
WA_Width, SZ_GetWindowWidth(),
WA_Height, SZ_GetWindowHeight(),
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Window -> WScreen,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | BUTTONIDCMP | CYCLEIDCMP,
WA_Title, LocaleString(MSG_TRANSLATIONPANEL_CHARACTER_TABLE_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG IClass,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
UBYTE DummyBuffer[256],
*DummyChar;
struct FileRequester *FileRequest;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
ActiveGadget = NULL;
SetSignal(0,SIG_BREAK);
while(!Terminated)
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
IClass = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(IClass == IDCMP_VANILLAKEY)
KeySelect(GadgetArray,MAINGAD_CANCEL,Code,PanelWindow,&Gadget,&IClass,&Code);
if(IClass == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
if(IClass == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case MAINGAD_HALF:
BlockWindow(PanelWindow);
Half = Code;
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
FreeGadgets(GadgetList);
GadgetList = NULL;
memset(GadgetArray,0,sizeof(struct Gadget *) * (MAINGAD_CANCEL + 1));
if(CreateAllMainGadgets(GadgetArray,&GadgetList,&Half))
{
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
ActiveGadget = NULL;
}
ReleaseWindow(PanelWindow);
break;
case MAINGAD_LOAD:
strcpy(DummyBuffer,LastTranslation);
DummyChar = PathPart(DummyBuffer);
*DummyChar = 0;
BlockWindow(PanelWindow);
if(FileRequest = GetFile(LocaleString(MSG_TRANSLATIONPANEL_LOAD_TRANSLATION_TABLES_TXT),DummyBuffer,FilePart(LastTranslation),DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_LOAD_TXT),TRUE))
{
struct TranslationEntry **Send,**Receive = NULL;
BYTE Success = FALSE;
if(Send = AllocTranslationTable())
{
if(Receive = AllocTranslationTable())
Success = LoadTranslationTables(DummyBuffer,Send,Receive);
}
if(!Success)
{
MyEasyRequest(Window,LocaleString(MSG_TRANSLATIONPANEL_COULD_NOT_LOAD_TRANSLATION_TABLES_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),DummyBuffer);
if(Send)
FreeTranslationTable(Send);
if(Receive)
FreeTranslationTable(Receive);
}
else
{
strcpy(Config -> FileConfig -> TranslationFileName,DummyBuffer);
strcpy(LastTranslation,DummyBuffer);
MadeChanges = FALSE;
Created = FALSE;
FreeTranslationTable(SendTable);
FreeTranslationTable(ReceiveTable);
SendTable = Send;
ReceiveTable = Receive;
}
FreeAslRequest(FileRequest);
}
ReleaseWindow(PanelWindow);
break;
case MAINGAD_SAVE:
strcpy(DummyBuffer,LastTranslation);
DummyChar = PathPart(DummyBuffer);
*DummyChar = 0;
BlockWindow(PanelWindow);
if(FileRequest = GetFile(LocaleString(MSG_TRANSLATIONPANEL_SAVE_TRANSLATION_TABLES_TXT),DummyBuffer,FilePart(LastTranslation),DummyBuffer,"#?.prefs",TRUE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SAVE_TXT),TRUE))
{
if(!SaveTranslationTables(DummyBuffer,SendTable,ReceiveTable))
MyEasyRequest(Window,LocaleString(MSG_TRANSLATIONPANEL_COULD_NOT_SAVE_TRANSLATION_TABLES_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),DummyBuffer);
else
{
strcpy(LastTranslation,DummyBuffer);
MadeChanges = FALSE;
Created = FALSE;
}
FreeAslRequest(FileRequest);
}
ReleaseWindow(PanelWindow);
break;
case MAINGAD_USE:
strcpy(Config -> FileConfig -> TranslationFileName,LastTranslation);
Terminated = TRUE;
break;
case MAINGAD_CANCEL:
Terminated = TRUE;
break;
default:
if(Gadget -> GadgetID < 256)
{
BlockWindow(PanelWindow);
MadeChanges |= SubPanel(Gadget -> GadgetID);
ReleaseWindow(PanelWindow);
}
break;
}
}
}
}
if(GadgetList)
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
}
FreeGadgets(GadgetList);
FreeVec(GadgetArray);
}
if(!MadeChanges && Created || (IsStandardTable(SendTable) && IsStandardTable(ReceiveTable)))
{
FreeTranslationTable(SendTable);
SendTable = NULL;
FreeTranslationTable(ReceiveTable);
ReceiveTable = NULL;
}
return(MadeChanges);
}